package com.ruyuan.scholartrade.controller;

import com.scholar.shop.common.CommonRes;
import com.scholar.shop.trad.pintuangoos.api.PintuanGoodsAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 拼团默认实现类
 *
 * @author zh
 * @version v7.0
 * @date 19/3/5 下午2:22
 * @since v7.0
 */
@CrossOrigin
@RestController
@RequestMapping("/trade/pintuanGoods/open/api")
public class PintuanGoodsAPIController {
   @Autowired
   private PintuanGoodsAPI pintuanGoodsAPI ;

    
    @PostMapping("/{promotionId}")
    public CommonRes<Boolean> createGoodsIndex(@PathVariable Integer promotionId) {
       return  pintuanGoodsAPI.createGoodsIndex(promotionId);
    }

    
    @DeleteMapping("/deleteIndex/{goodsId}")
    public CommonRes<Boolean> deleteIndexByGoodsId(@PathVariable Integer goodsId) {

        pintuanGoodsAPI.deleteIndexByGoodsId(goodsId) ;
        return CommonRes.success(true) ;
    }

    
    @PostMapping("/sync/{goodsId}")
    public CommonRes<Boolean> syncIndexByGoodsId(@PathVariable Integer goodsId) {
        return this.pintuanGoodsAPI.syncIndexByGoodsId(goodsId) ;
    }

    
    @DeleteMapping("/delete/{goodsId}")
    public CommonRes<Boolean> delete(@PathVariable Integer goodsId) {

        return this.pintuanGoodsAPI.delete(goodsId) ;
    }
}
